package com.vue.admin.service.common.mybatis.entity;

import java.sql.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: vue-admin-service
 * @description: sql 查询参数实体类
 * @author: zhangyangyang
 * @create: 2020-04-03 11:03
 **/
public class Query extends HashMap<String, Object> {

    public Query() {
        super();
    }

    public Query(Map<String, Object> params) {
        this.putAll(params);
    }

    public Boolean getAsBoolean(String name) {
        Object value = this.get(name);
        if(value != null) {
            return Boolean.valueOf(value.toString());
        }
        return null;
    }

    public java.util.Date getAsDate(String name) {
        Object value = this.get(name);
        if(value != null) {
            return Date.valueOf(value.toString());
        }
        return null;
    }

    public Double getAsDouble(String name) {
        Object value = this.get(name);
        if(value != null) {
            return Double.valueOf(value.toString());
        }
        return null;
    }

    public Integer getAsInt(String name) {
        Object value = this.get(name);
        if(value != null) {
            return Integer.valueOf(value.toString());
        }
        return null;
    }

    public Long getAsLong(String name) {
        Object value = this.get(name);
        if(value != null) {
            return Long.valueOf(value.toString());
        }
        return null;
    }

    public String getAsString(String name) {
        return this.get(name).toString();
    }

    public Object getObj(String name) {
        return this.get(name);
    }
}
